var vm =  new Vue({
      el : "#app",
      data : {
      house_num:1,//房间数
      //pickerValue:'14:00',
      break_num:0,//早餐券，
      cont_show_:true,
      userId:'',//缓存客户id
      code:'',//code 提交订单需要
      groupId:'',//groupId 同上
      break_num_self:1,//默认早餐券，传过来吧
      start:'',//入住时间
      end:'',//离店时间
      roomTypeId:'',//房间类型id
      hotel:'',//分店id
      name:'',//预订
      hotelName:'',//酒店名
      mobile:'',//手机号
      remark:'',//备注
      reserveCount:'',//可定间数
      roomTypeName:'',//房型名字
      day_time:1,//入住天数
      unit_pricr:'',//会员单价
      price2:'',//门市价
      break_pricr:'20',//早餐券价
      //add_pricr:'',//计算属性总价
      total:'',//最终总价
      input:'',
      token:'',//公共id
      time_val:'',
      time_this:'14:00',
      //time_this:'',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           0',//选择的时间
      alert_time_show:false,
      reset_show:false,
      into_time:'12:00'
      },
created:function(){
   // alert(1)
  // var that=this;
  // var pp=$('#demo3').val();
  // setInterval(function(){
  //   alert(that.time_this);
  // },5000)
this.unit_pricr = _lSGet('price');//会员价
this.price2 = _lSGet('price2');//门市价
this.hotel = _lSGet('hotelId');//酒店id//这里是上上个页面传的非上个
this.break_num_self = _lSGet('breakCount');//早餐券这里是上上个页面传的非上个
//alert(this.break_num_self)
//alert(this.hotel);
this.roomTypeId = _lSGet('roomTypeId');//房型id
this.roomTypeName = _lSGet('roomTypeName');//房型名称
this.token = _lSGet('token');
this.userId = _lSGet('userId');
//alert(this.token);
this.start = _lSGet('start');//获取上个页面传的入店时间
this.end = _lSGet('end');//获取上个页面传的离店时间
this.day_time = _lSGet('day_time');//获取上个页面传入的入住天数
this.code = _lSGet('code');//获取上上个传入的
this.groupId = _lSGet('groupId');//获取上上个页面传入
this.reserveCount = _lSGet('reserveCount');//可定间数
this.hotelName = _lSGet('hotelName');//酒店名
    //alert(this.hotelName)
//this.unit_pricr = _lSGet('unitPrice');//获取上个页面传入的房间单价
    //alert(this.reserveCount);


  },
mounted:function(){
    var that=this;
  var calendartime = new LCalendar();
  calendartime.init({
        'trigger': '#demo3',
        'type': 'time'
    });

    var that=this;
    setTimeout(function(){//下面解决点击白块空白
        // $('.ta_calendar').css('background-color','red');
        $('.ta_calendar').css({
            'margin-top':'-35px',
            // 'background-color' :'red'
        })   ;
        $('.ta_calendar_footer').css({
            'margin-bottom':'10rem',
            // 'background-color' :'red'
        });
        $('.frm_msg').css('display','none');//把日历input框隐藏
    },200)
    //日历插件
    this.dateRange1 = new pickerDateRange('date1', {
        aRecent90Days : 'aRecent90Days', //最近90天
        //isTodayValid : true,
        isTodayValid : true,
        startDate:that.start,
        //startDate: that.start,
        endDate: that.end,//这里改以前的时间会悬赏
        magicSelect : false,
        needCompare : false,
        defaultText : '离开',
        autoSubmit : false,
        //stopToday : false,
        //autoSubmit : true,
        inputTrigger : 'input_trigger1',
        theme : 'ta',
        success : function(obj) {//点击确认按钮
            that.cont_show_=true;//让页面显示
            //alert('ok')
            console.log(obj)
            that.end=obj.endDate;
            that.start=obj.startDate;
            //alert(obj.startDate)
            //router.replace('/index-cont?id='+this.id+'&start='+start+'&end='+end+'')
        }
    });
  },
methods:{
  add_num_hou:function(){
      //alert(1)
      //if(this.reserveCount<=this.house_num){
      //    tips('不能大于可订房间数');
      //    return;
      //}
  this.house_num+=1;
      //console.log(this.input);
      //$('.people-right-add').append(this.input);//二期打开
  },
    go_time:function(){
        var that=this;
        setTimeout(function(){
            $('#date1').click();
            that.cont_show_=false;
            //$('.cf').css('display','none')
        },10)

    },
  go_login_home:function(res){
  if(res.returnCode=="MEM-1001"){
      window.location.href=backUrl;
     }
    },
    // show_ctrl:function(){
    //     this.alert_time_show=false;
    // },
  set_time:function(){
      $('#demo3').click();
    },
  bottom_list:function(){
  //var htm='<p style="text-align: left;">入住一晚总价：<span>'+this.unit_pricr+'</span></p><p style="text-align: left;">门市价：<span>'+this.price2+'</span></p><p style="text-align: left;">总额<span>'+this.total+'</span></p>'
  //layer.open({
  //  className: 'me-class'
  //  ,content: htm
  //  ,btn: '确认'
  //   });
      this.reset_show=true;
    },
    // get_time:function(){
        
    //     //alert(this.time_val)
    //     var cont_=$('input:radio:checked').val();//获取值
    //     this.into_time=cont_;
    //     this.alert_time_show=false;
    // },
    go_payment:function(){
        if(this.day_time==0){
           tips('时间选择不正确');
            return;
        }
      var that=this;
      if (that.name!=''&that.mobile!='') {
          layer.open({
    content: '在线支付必须在半小时内付款才能预订成功，半小时内不付款，订单将自动取消，敬请谅解!'
    ,btn: ['确认', '取消']
    ,yes: function(index){
    //location.reload();
    //alert('这里写ajax')
    
    var params = {};
    params.reserveName = that.name;//客人名称
    params.hotelId =that.hotel;//传过来的酒店id
    //params.hotel =3;
    params.roomTypeId = that.roomTypeId;//房间类型id
    params.roomTypeName = that.roomTypeName;//房间类型名字
    //params.price1 = that.unit_pricr;
    params.mobile = that.mobile;//手机号
    params.inTime = that.start.replace(/-/g, "/")+' '+that.time_this+':00';
    //params.inTime = that.start.replace(/-/g, "/"); 
    params.outTime = that.end.replace(/-/g, "/")+' '+'23:59:59'; 
    //params.inTime = `2017/09/27`;
    //params.outTime = `2017/09/30`;
    // params.roomsNum = that.house_num;
    params.roomCount = that.house_num;//房间数
    params.roomPrice = that.unit_pricr;//房间数
    params.unpaidMoney = that.total;//总房费
    //params.reserveMoney = that.total;//总房费
    params.customId = that.userId;//客户id
    params.dayCount = that.day_time;//入住天数
    params.defaultBreakfast = that.break_num_self;//自带早餐数
    params.actualBreakfast = that.break_num;//早餐数
    params.token = that.token;//公用token
    params.groupId = that.groupId;//上上也传过来的
    params.hotelCode = that.code;//同上
    params.remark = that.remark;
    $.ajax({
      type: "post",
      contentType: 'application/json;charset=utf-8',
      url:url+'/weChartOrder/edit',
      data:JSON.stringify(params),
      cache:false, 
      //contentType:'application/x-www-form-urlencoded',
      async:true, 
      //dataType: 'json',
      success: function(res){
      goLogin(res);//公用回家
          tips(res.returnMsg);
       if(res.status==1){
          _lSSaveOrUpdate( 'reserveId',res.data);//保存订单号
          window.location.href=indexUrl+'/app/payment.html?_t=' + Math.random();
          }
         }
      });
      layer.close(index);
      }
    });       
      } else{
    layer.open({
        content: '请填写完整的信息'
        ,skin: 'msg'
        ,time: 2 //2秒后自动关闭
    });
      };
    
    },
    sub_num_hou:function(){  
      if(this.house_num>1){
        this.house_num-=1;
      }
     // $('.people-right-add input:eq('+this.house_num+')').remove();//二期打开
    },
    sub_num_break:function(){
      if(this.break_num>0){
        this.break_num-=1;
      }
    },
    add_num_break:function(){


      this.break_num+=1;

    },
       
  },
  computed: {
    add_pricr:function(){
      //alert(this.unit_pricr);
    this.total= this.unit_pricr*this.house_num*this.day_time;
    //this.total= 500*this.house_num*this.day_time;
    //console.log(this.unit_pricr) 
    return this.total;
    } ,
      days:function(){//计算天数
          var start_d= Date.parse(this.start.replace(/-/g,"/"));
          var end_d= Date.parse(this.end.replace(/-/g,"/"));
          var dayCount = Math.floor((Math.abs(start_d - end_d))/1000/60/60/24);
          this.day_time=dayCount;
          //alert(dayCount);
          return dayCount;
      }
 },
 watch:{
     house_num:function(){
        // alert(this.reserveCount);
        // alert(this.house_num);
         if(this.reserveCount<=this.house_num){
            // alert(1)
             tips('不能大于可订房间数');

             this.house_num=this.reserveCount;
         }
     }
 },

 components:{
        
  }
 
      
});